//自定义弹窗
import 'package:flutter/material.dart';
import 'package:online_study/theme/colors.dart';
import 'package:online_study/theme/size.dart';

class AlertUtils {
  static AlertDialog haveCloseDialog(
      String title,
      Color titleColor,
      String content,
      String bottomText,
      final VoidCallback onClosePressed,
      final GestureTapCallback onTap) {
    return AlertDialog(
      title: Column(
        children: [
          Container(
            alignment: Alignment.topRight,
            // margin: EdgeInsets.symmetric(vertical: ThemeSize.height20),
            child: CloseButton(
              onPressed: onClosePressed,
            ),
          ),
          Text(title,
              style: TextStyle(
                  color: ThemeColor.color333333,
                  fontSize: ThemeSize.sp16,
                  fontWeight: FontWeight.bold))
        ],
      ),
      titlePadding: EdgeInsets.symmetric(horizontal: ThemeSize.width19),
      insetPadding: EdgeInsets.zero,
      content: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(content,
              style: TextStyle(
                  color: ThemeColor.color555555, fontSize: ThemeSize.sp13),
              textAlign: TextAlign.center,
              softWrap: true),
          Container(
              height: ThemeSize.height76,
              alignment: Alignment.center,
              child: GestureDetector(
                child: Container(
                  height: ThemeSize.height36,
                  alignment: Alignment.center,
                  padding: EdgeInsets.symmetric(horizontal: ThemeSize.width12),
                  decoration: BoxDecoration(
                      color: ThemeColor.colorFA5151,
                      borderRadius: BorderRadius.circular(ThemeSize.height18)),
                  child: Text(bottomText,
                      style: TextStyle(
                          color: ThemeColor.colorWhite,
                          fontSize: ThemeSize.sp16)),
                ),
                onTap: onTap,
              ))
        ],
      ),
      contentPadding: EdgeInsets.only(
          left: ThemeSize.width19,
          right: ThemeSize.width19,
          top: ThemeSize.height10),
      backgroundColor: ThemeColor.colorWhite,
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(ThemeSize.height8))),
    );
  }

  static AlertDialog noCloseAlertDialog(
      String title,
      String content,
      String bottomLeftText,
      GestureTapCallback onLeftTap,
      String bottomRightText,
      GestureTapCallback onRightTap) {
    return AlertDialog(
      title: Text(
        title,
        style: TextStyle(
            color: ThemeColor.color333333,
            fontSize: ThemeSize.sp16,
            fontWeight: FontWeight.bold),
        softWrap: true,
        textAlign: TextAlign.center,
      ),
      titlePadding: EdgeInsets.symmetric(
          horizontal: ThemeSize.width19, vertical: ThemeSize.height20),
      insetPadding: EdgeInsets.zero,
      content: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          (content.isEmpty)
              ? Container()
              : Text(content,
                  style: TextStyle(
                      color: ThemeColor.color555555, fontSize: ThemeSize.sp13),
                  textAlign: TextAlign.center,
                  softWrap: true),
          Row(
            children: [
              Flexible(
                  child: Container(
                      padding:
                          EdgeInsets.symmetric(horizontal: ThemeSize.width12),
                      height: ThemeSize.height76,
                      alignment: Alignment.center,
                      child: GestureDetector(
                        child: Container(
                          height: ThemeSize.height36,
                          alignment: Alignment.center,
                          padding: EdgeInsets.symmetric(
                              horizontal: ThemeSize.width12),
                          decoration: BoxDecoration(
                              color: ThemeColor.colorEEF7FF,
                              borderRadius:
                                  BorderRadius.circular(ThemeSize.height18)),
                          child: Text(bottomLeftText,
                              style: TextStyle(
                                  color: ThemeColor.color1485EE,
                                  fontSize: ThemeSize.sp16)),
                        ),
                        onTap: onLeftTap,
                      ))),
              Flexible(
                  child: Container(
                      padding:
                          EdgeInsets.symmetric(horizontal: ThemeSize.width12),
                      height: ThemeSize.height76,
                      alignment: Alignment.center,
                      child: GestureDetector(
                        child: Container(
                          height: ThemeSize.height36,
                          alignment: Alignment.center,
                          padding: EdgeInsets.symmetric(
                              horizontal: ThemeSize.width12),
                          decoration: BoxDecoration(
                              color: ThemeColor.colorFA5151,
                              borderRadius:
                                  BorderRadius.circular(ThemeSize.height18)),
                          child: Text(bottomRightText,
                              style: TextStyle(
                                  color: ThemeColor.colorWhite,
                                  fontSize: ThemeSize.sp16)),
                        ),
                        onTap: onRightTap,
                      ))),
            ],
          )
        ],
      ),
      contentPadding: EdgeInsets.zero,
      backgroundColor: ThemeColor.colorWhite,
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(ThemeSize.height8))),
    );
  }
}
